#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 1e4 + 5;
struct car{
    int d, v, a;
}c[N];
bool p[M][M];
int n, m, l, v;
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    while (t--) {
        int ans = 0;
        vector<int> checkers;
        cin >> n >> m >> l >> v;
        for (int i = 1; i <= n; i++) {
            cin >> c[i].d >> c[i].v >> c[i].a;
        }
        int in;
        for (int i = 1; i <= m; i++) {
            cin >> in;
            checkers.push_back(in);
        }
        for (int i = 1; i <= n; i++) {
            int o = false;
            for (auto it : checkers) {
                if (v * v < c[i].v * c[i].v + 2 * c[i].a * it) {
                    if (!o) {
                        o = true;
                        ans++;
                    }
                p[i][it] = true;
                }
            }
        }
        cout << ans << " " << ans << endl;
    }
    return 0;
}
